package com.woniuxy.yuekeuser.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.yuekeuser.model.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import javax.websocket.server.ServerEndpoint;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Freedom
 * @since 2020-11-03
 */
public interface OrderMapper extends BaseMapper<Order> {
//动态sql查询
    IPage<Order> getUserOrder(int userId,String state,Page<Order> page);

    //商家查询自己的订单
    public List<Order> findBusinesOrder(@Param(value = "userId")int userId,@Param(value = "state")String state,
                                  @Param(value = "index")int index,@Param(value = "size")int size);

    //商家查询自己的订单条数
    public int findBusinesOrderCount(@Param(value = "userId")int userId, @Param(value = "state")String state);


    //查询现有所有待付款订单。为了判断订单付款时间是否超出
    @Select("select order_id,order_type,user_id,shop_id,commodity_id,order_price,order_time,order_endtime,order_state,downorder_time from t_order where order_state ='待付款'")
    public List<Order> findOrderall();


    //根据订单id删除订单
    @Delete("delete from t_order where order_id = #{orderId}")
    public void deleteOrderByOrder(Order order);

}
